const express = require("express")
const bodyParser = require("body-parser")
// const router = express.Router();
const homeRouter = require("./routes/home")
const newsRouter = require("./routes/new")
const uploadRouter = require("./routes/upload")
const app = express()


app.use(bodyParser.urlencoded({extended:false}))
app.use(bodyParser.json())
app.use(express.static("./public"))


// 设置模板引擎

app.set("views","./views")
app.set("view engine","ejs")
// home new login

/* router.use((req,res,next)=>{
    console.log("我是全局中间件了")
    next();
});

router.get("/home",(req,res)=>{
    res.send("home页")
})
router.post("/home",(req,res)=>{
    res.send("home页post方法")
})
router.get("/news",(req,res)=>{
    res.send("news页")
})
router.get("/login",(req,res)=>{
    res.send("登录页")
})

app.use(router) */

app.use(homeRouter)
app.use(newsRouter)
app.use(uploadRouter)
app.listen(3000,()=>{console.log("start at port 3000")})
